from PyQt4 import QtCore, QtGui

class FrameInfo():
    """Object to hold information for photo crop frame information"""
    def __init__(self):
        self.pos = QtCore.QPoint(0,0)
        self.size= QtCore.QSize(200,257)                # frame size draw on screen
        self.t_size= QtCore.QSize(400,514)              # output file size
        self.h1_pos = QtCore.QPoint(50,17)              # horizontal line 1,2,3
        self.h2_pos = QtCore.QPoint(50,160)
        self.h3_pos = QtCore.QPoint(50,215)
        self.v_pos = QtCore.QPoint(100, 17)             # vertical line
    
    def setSize(self, w, h):
        """ Set frame size"""
        self.size.setWidth(w)
        self.size.setHeight(h)
          
    def setPos(self, x, y):
        """ Set absolute position for the frame"""
        self.pos.setX(x)
        self.pos.setY(y)
        
    def setTargetSize(self, w, h):
        self.t_size.setWidth(w)
        self.t_size.setHeight(h)
        
    def setH1Pos(self, x, y):
        """ Set position relative to frame position, not absolute value"""
        self.h1_pos.setX(x)
        self.h1_pos.setY(y)
        
    def setH2Pos(self, x, y):
        """ Set position relative to frame position, not absolute value"""
        self.h2_pos.setX(x)
        self.h2_pos.setY(y)
        
    def setH3Pos(self, x, y):
        """ Set position relative to frame position, not absolute value"""
        self.h3_pos.setX(x)
        self.h3_pos.setY(y)
    
    def setVPos(self, x, y):
        """ Set position relative to frame position, not absolute value"""
        self.v_pos.setX(x)
        self.v_pos.setY(y)
        
    def getFrameRect(self):
        """ get the frame size"""
        return QtCore.QRect(self.pos, self.size)
   
    def getSize(self):
        return self.size
    
    def getPos(self):
        return self.pos
    
    def getTargetSize(self):
        return self.t_size
    
    def getH1Line(self):
        """ Get absolute position value for line 1"""
        pos1 = self.h1_pos + self.pos
        pos2 = QtCore.QPoint(pos1.x()+self.size.width()/2, pos1.y())
        return QtCore.QLine(pos1,pos2)      
        
    def getH2Line(self):
        """ Get absolute position value for line 2"""
        pos1 = self.h2_pos + self.pos
        pos2 = QtCore.QPoint(pos1.x()+self.size.width()/2, pos1.y())
        return QtCore.QLine(pos1,pos2)

    def getH3Line(self):
        """ Get absolute position value for line 3"""
        pos1 = self.h3_pos + self.pos
        pos2 = QtCore.QPoint(pos1.x()+self.size.width()/2, pos1.y())
        return QtCore.QLine(pos1,pos2)
        
    def getVLine(self):
        """ Get absolute position value for vertical line"""
        pos1 = self.v_pos + self.pos
        pos2 = QtCore.QPoint(pos1.x(), (pos1.y() + self.h3_pos.y() - self.h1_pos.y()))
        return QtCore.QLine(pos1,pos2)
